<extend name="Public:base" />
<block name="Controller">Appindex</block>
<block name="Main">
    <div class="col-md-10 main padding">
        <div class="cf">
          <div class="fl"><h2>App选择切换</h2></div>
          <div class="fr"><button ms-click="openModal('.addApp')" type="button" class="btn btn-xm btn-success">新建</button> </div>
        </div>
        <hr />
        <ul class="md-block-grid-4 margin-top margin-left">
        <li ms-repeat="applist" class="padding-right " >
            <div class="panel panel-primary">
                <div class="panel-hd">{{el.title}}</div>
                <div class="panel-bd">                    
                    {{el.desc}}
                </div>
                <footer class="panel-footer padding-left-none padding-right-none text-center">
                    <div class="btn-group">
                    <button class="btn btn-success btn-xs"><i class="icon-eye"></i>
                    预览</button>
                    <a ms-href="{:U("Admin/AppInfo/index")}&appid={{el.id}}" class="btn btn-primary btn-xs"><i class="icon-retweet"></i>
                    设计</a>
                    <button ms-click="deleteEl($remove,el)" href="{:U("Admin/AppInfo/delete")}" class="btn btn-danger btn-xs"><i class="icon-trash-o"></i>
                    删除</button>
                    </div>
                </footer>
            </div>
        </li>
        </ul>

    </div>
<div data-modal class="popup addApp" >
  <div class="popup-inner">
    <div class="popup-hd">
      <h4 class="popup-title">新建App</h4>
      <span data-modal-close
            class="close">&times;</span>
    </div>
    <div class="popup-bd">
      <form method="post" action="{:U('Admin/AppInfo/create')}" class="form capp">
        <fieldset>
          <div class="form-group">
            <label for="ipt-title">App名称</label>
            <input type="text" id="ipt-title" name="title" >
          </div>
          <div class="form-group">
            <label for="ipt-intro">App描述</label>
            <textarea name="intro" rows="5" id="ipt-intro"></textarea>
          </div>
        </fieldset>
        <p><button ms-click="creatApp()" type="button" class="btn btn-default">确定</button></p>
      </form>
    </div>
  </div>
</div>
<load href="Public/easyapps/js/EasyApps.js" />
<script type="text/javascript">

require("mmRouter,nprogress/nprogress,jquery,app", function(avalon,nprogress,$,app) {

    var Appindex = avalon.define('Appindex', function(vm) {
        vm.applist = eval('({$applist})');
        vm.creatApp = function(){
          var url = "{:U('Admin/AppInfo/create')}";
          var map = $('form.capp').find('input').serialize();
            nprogress.start();
          $.post(url,map,function(resq){
            app.hideModal('.addApp');
            window.location.reload();
            nprogress.done();
          })

        }
    })
    
    avalon.scan()
}) 

</script>   
</block>